<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>客户详情</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            background-color: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        h1, h2 {
            color: #333;
        }
        .customer-info {
            margin-bottom: 30px;
        }
        .info-item {
            margin-bottom: 10px;
        }
        .info-label {
            font-weight: bold;
            display: inline-block;
            width: 100px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            padding: 10px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
        .back-link {
            display: inline-block;
            margin-top: 20px;
            color: #4CAF50;
            text-decoration: none;
        }
        .back-link:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>客户详情</h1>
        
        <div class="customer-info">
            <div class="info-item">
                <span class="info-label">客户ID:</span>
                <span>${customer.customerId}</span>
            </div>
            <div class="info-item">
                <span class="info-label">客户名称:</span>
                <span>${customer.customerName}</span>
            </div>
            <div class="info-item">
                <span class="info-label">联系邮箱:</span>
                <span>${customer.contactEmail}</span>
            </div>
            <div class="info-item">
                <span class="info-label">城市:</span>
                <span>${customer.city}</span>
            </div>
        </div>
        
        <h2>订单列表</h2>
        <c:choose>
            <c:when test="${not empty customer.orders}">
                <table>
                    <thead>
                        <tr>
                            <th>订单ID</th>
                            <th>订单日期</th>
                            <th>总金额</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <c:forEach items="${customer.orders}" var="order">
                            <tr>
                                <td>${order.orderId}</td>
                                <td><fmt:formatDate value="${order.orderDate}" pattern="yyyy-MM-dd"/></td>
                                <td>${order.totalAmount}</td>
                                <td>${order.status}</td>
                                <td>
                                    <a href="<c:url value='/order/detail/${order.orderId}'/>">查看详情</a>
                                </td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
            </c:when>
            <c:otherwise>
                <p>该客户暂无订单</p>
            </c:otherwise>
        </c:choose>
        
        <a href="<c:url value='/customer/list'/>" class="back-link">返回客户列表</a>
    </div>
</body>
</html>
